#include "cfcafx.h"
#include "conio.h"
class CHelloWorld
    :public CStaticText {
public:
    CHelloWorld()
    {
        cfcgl::background->AppendChild(this);
        this->SetRel(Relation::fixed);
        this->SetPos({ 2, 1 });
        this->resize({ 11,1 });
        this->SetzIndex(11);
        this->SetInnerText("$C0f2b48f6U;Hello $Fffeeffu;World");
        this->Show(true);
    }
    void a()
    {
        this->resize({ 8,2 });
    }
    void b()
    {
        this->SetPos({ 0,3 });
    }
};
class CBack :
    public CDiv {
public:
    CBack()
    {
        cfcgl::background->AppendChild(this);
        this->SetRel(Relation::fixed);
        this->SetPos({ 0,0 });
        this->resize({ 15,5 });
        this->Show(true);
        this->BackgroundColor(201, 166, 65);
    }
};

class CMain :
    public CFrameApp
{
    int ch;
    const static int IDT_ARROW = 1;
    const static int IDT_PC = 2;
public:
    void onTimer(ID ctid) override
    {
        switch (ctid)
        {
        case IDT_PC:
            putchar(ch);
            break;
        case IDT_ARROW:
            if (_kbhit())
            {
                ch = _getch();
                this->setTimer(IDT_PC, 5000, 0, nullptr);
            }
            break;
        default:break;
        }
    }
    void onload() {
        cfcgl::init({ 15, 5 }, true);
        this->setTimer(IDT_ARROW, 0, 1, nullptr);
    }
};
int main()
{/*
    cfcgl::init({ 15, 5 }, true);
    CBack* back = new CBack();
    CHelloWorld* hello_world = new CHelloWorld();
    if (cfcgl::ScreenUpdatePending)
        cfcgl::UpdateScreenUIBuffer();
    Sleep(1000);
    hello_world->a();
    if (cfcgl::ScreenUpdatePending)
        cfcgl::UpdateScreenUIBuffer();
    Sleep(1000);
    hello_world->b();
    if (cfcgl::ScreenUpdatePending)
        cfcgl::UpdateScreenUIBuffer();
    Sleep(1000);
    delete hello_world;
    delete back;
    if (cfcgl::ScreenUpdatePending)
        cfcgl::UpdateScreenUIBuffer();*/
    CMain cmain;
    cmain.onload();
    cmain.timer();
}